import scrapy
import socket
import socks
import requests
import faker

import os
import sys



class TsSpider(scrapy.Spider):
	# name = 'ts'
	allowed_domains = ['amazonaws.com']
	start_urls = ['http://checkip.amazonaws.com/']

	# he = faker.Faker(locale="zh_CN").user_agent()

	# header = {
	# "User-Agent":he
	# }

	# def ht():
	# 	print("hell world")

	# 	# he = faker.Faker(locale="zh_CN").user_agent()

	# 	# header = {
	# 	# "User-Agent":he
	# 	# }

	# 	res = os.system("sudo /etc/init.d/tor restart")
	
	# 	socks.set_default_proxy(socks.SOCKS5,"127.0.0.1",9050)
	# 	socket.socket = socks.socksocket
	# 	a = requests.get("http://checkip.amazonaws.com").text
	# 	if res == 0:
	# 		print("更换ip成功:"+a)
	# 	b = requests.get("https://www.meituan.com")
	# 	print(b)

	# 	sys.exit(0)

	ht()

	# def start_requests(self):
	# 	socks.set_default_proxy(socks.SOCKS5,"127.0.0.1",9050)
	# 	socket.socket = socks.socksocket
	# 	url = "http://checkip.amazonaws.com"
	# 	scrapy.Request(url,callback=self.parse)

	def parse(self, response):
		pass
		# a = response.text
		# a = a.split()
		# a[0]



